@extends('adminDialog')
@section('content')
    <form action="{{url('admin/marriage/update/'.$model->id)}}" method="POST" class="J_ajaxForm"
          style="height:  height: 599px;">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="pop_cont pop_table" style="overflow-y: scroll;height: 529px;">
            <table width="100%">
                <tbody>

                <tr>
                    <th><label for="title">姓名 <span class="red">*</span></label></th>
                    <td>
                        <input type="text" name="name" id="name" class="input length_6"
                               value="{{$model->name}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="">个人照片</label></th>
                    <td>
                        <a href="javascript:;" id="pic" class="pic" title="选择上传文件">
                            <input type="hidden" name="pic" value="{{$model->pic}}"/>
                            <img src="/img/marriage-{{ $model->pic }}/290-320" onerror="this.src='{{url("images/14417770931301.png")}}'"/>
                        </a>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">性别 <span class="red">*</span></label></th>
                    <td>
                        <input type="radio" name="age" id="sex" class="input" value="0" @if(1 != $model->sex)checked="checked"@endif/>男
                        <input type="radio" name="age" id="sex" class="input" value="1" @if(1 == $model->sex)checked="checked"@endif/>女
                    </td>
                </tr>
                <tr>
                    <th><label for="title">年龄 <span class="red">*</span></label></th>
                    <td>
                        <input type="text" name="age" id="age" class="input length_6"
                               value="{{$model->age}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">联系方式 <span class="red">*</span></label></th>
                    <td>
                        <input type="text" name="tel" id="tel" class="input length_6"
                               value="{{$model->tel}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">身高 </label></th>
                    <td>
                        <input type="text" name="rise" id="rise" class="input length_6"
                               value="{{$model->rise}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">体重 </label></th>
                    <td>
                        <input type="text" name="weight" id="weight" class="input length_6"
                               value="{{$model->weight}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">学历 </label></th>
                    <td>
                        <input type="text" name="education" id="education" class="input length_6"
                               value="{{$model->education}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">名族 </label></th>
                    <td>
                        <input type="text" name="minority" id="minority" class="input length_6"
                               value="{{$model->minority}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">星座 </label></th>
                    <td>
                        <input type="text" name="zodiac" id="zodiac" class="input length_6"
                               value="{{$model->zodiac}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">属相 </label></th>
                    <td>
                        <input type="text" name="horoscope" id="horoscope" class="input length_6"
                               value="{{$model->horoscope}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="keywords">家庭住址 <span class="red">*</span></label></th>
                    <td>
                        <select data-address="{{$model->address}}" id="s_province" name="s_province"></select>&nbsp;&nbsp;
                        <select data-address="{{$model->address}}" id="s_city" name="s_city"></select>&nbsp;&nbsp;
                        <select data-address="{{$model->address}}" id="s_county" name="s_county"></select></br>
                        <input type="text" name="address" id="address" class="input length_6"  value="{{json_decode($model->address,true)['detial']}}" style="margin-top: 10px;"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">工作 </label></th>
                    <td>
                        <input type="text" name="job" id="job" class="input length_6"
                               value="{{$model->job}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="title">爱好 </label></th>
                    <td>
                        <input type="text" name="hobby" id="hobby" class="input length_6"
                               value="{{$model->hobby}}"/>
                    </td>
                </tr>
                <tr>
                    <th><label for="content">详细信息 <span class="red">*</span></label></th>
                    <td>
                        <script id="container" name="content" type="text/plain">
                            {!! $model->content !!}
                        </script>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="pop_bottom cc">
            <button type="reset" class="btn fr" id="J_dialog_close">取消</button>
            <button type="submit" class="btn btn_submit J_ajax_submit_btn fr mr10" id="J_dialog_close">提交</button>
        </div>
    </form>
@stop

@section('style')
    <style>
        .body_none {
            width: 720px;
        }
    </style>
@stop

@section('js')
    @parent
    @include('UEditor::head')
    <script src="{{ asset('js/plupload/plupload.full.min.js') }}"></script>
    <script src="{{asset("js/jsAddress.js")}}"></script>
    <script>
        var ue = UE.getEditor('container', {
            initialFrameWidth: 600, initialFrameHeight: 150, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage']
            ]
        });
        ue.ready(function () {
            ue.execCommand('serverparam', '_token',  '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
    </script>
    <script>
        $(function(){
            var location  = @if("" == $model->address) "" @else {!! $model->address !!} @endif;
            if(location && location.s_province){
                addressInit('s_province', 's_city', 's_county',location.s_province, location.s_city, location.s_county);
            }else{
                addressInit('s_province', 's_city', 's_county', '浙江', '杭州市', '上城区');
            }

        })
    </script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'client_pic', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '5mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'client'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',
                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        //alert(response.state);
                        if (response.state == 'success') {
                            $('.client_pic img').attr('src', '{!! url("img/client-' + response.id + '/257-55") !!}');
                            $('.client_pic input').val(response.id);
                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();
        });
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pic', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '5mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'marriage'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',
                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        //alert(response.state);
                        if (response.state == 'success') {
                            $('.pic img').attr('src', '{!! url("img/marriage-' + response.id + '/290-320") !!}');
                            $('.pic input').val(response.id);
                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();
        });
    </script>
@stop
